package com.quanquan.management.service;

import com.alibaba.fastjson.JSONObject;
import com.quanquan.management.dto.DataDTO;
import com.quanquan.management.request.DataRequestBody;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import utils.Request;

/**
 * @ClassName:DataService
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/5/9 15:07
 * @Version 1.0
 */
@Service
public class DataService {

    @Value("${module-url.userUrl}")
    private String userUrl;

    public DataDTO findData() {
        DataRequestBody requestBody = new DataRequestBody();
        String json = Request.postJson(userUrl + "data/all_count", requestBody);
        JSONObject jsonObject = JSONObject.parseObject(json);
        Integer resCode = jsonObject.getInteger("resCode");
        DataDTO dataDTO = null;
        if (0 == resCode) {
            JSONObject data = jsonObject.getJSONObject("data");
            dataDTO = data.toJavaObject(DataDTO.class);
        }
        return dataDTO;
    }


}
